
//
//  CPJNavigationViewController.swift
//  Sina
//
//  Created by YYY on 2017/7/24.
//  Copyright © 2017年 成品家（北京）网路科技有限公司. All rights reserved.
//

import UIKit

class CPJNavigationViewController: UINavigationController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        navigationBar.isHidden = true
        // Do any additional setup after loading the view.
    }

    //push入栈，隐藏底部分栏
    override func pushViewController(_ viewController: UIViewController, animated: Bool) {
      
        if childViewControllers.count>0
        {
            viewController.hidesBottomBarWhenPushed = true
            
            var title = "返回"
            
            if let vc = viewController as? CPJBaseViewController  {
                if childViewControllers.count==1
                {
                    title = childViewControllers.first?.title ?? "返回"
                }
                vc.navitem.leftBarButtonItem = UIBarButtonItem(size: CGSize(width: 60, height: 30), titleStr: title, fontSize: 17, target: self, selector: #selector(popToBack), isBack:true)
            }
        }
        
        super.pushViewController(viewController, animated: true)
    }
    
    //返回上一级
    @objc func popToBack()
    {
        popViewController(animated: true)
    }
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
